package com.wobito.common.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.wobito.common.interceptor.CustomBlockAttackInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //分页插件
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        //防止全表更新插件
//        mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
        //自定义SQL拦截器，允许DDL
        mybatisPlusInterceptor.addInnerInterceptor(new CustomBlockAttackInnerInterceptor());
        return mybatisPlusInterceptor;
    }

}